# @desc : 注册路由
import os

from fastapi import FastAPI
from common import settings
from app.user import userController
from app.upload import router as uploadController
from app.common import commonController
from app.role import roleController
from app.group import groupController
from app.ws import WsEcho


# 注册路由
def register_router(app: FastAPI):
    controller_list = [
        {'router': userController, 'tags': ['用户管理']},
        {'router': uploadController, 'tags': ['附件上传']},
        {'router': commonController,  'tags': ['公共']},
        {'router': roleController, 'tags': ['用户角色']},
        {'router': groupController, 'tags': ['用户所属组织']},
    ]
    for controller in controller_list:
        app.include_router(controller.get('router'), prefix=settings.API_PREFIX, tags=controller.get('tags'))

    app.add_websocket_route(f'{settings.API_PREFIX}/ws', WsEcho)
